<img id="pic" 
src="pic_bulboff.gif" />
<button onclick="guanDeng()">关灯</button>



<script>
var i=1;
function guanDeng(){
if(i==1){
pic.src="pic_bulboff.gif";
i=0;
}else{
pic.src="pic_bulbon.gif";
i=1;
}
}
</script>